//
//  ShoppingLastlyCollectionViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/6/27.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "ShoppingLastlyCollectionViewCell.h"


@interface ShoppingLastlyCollectionViewCell ()

@property (strong, nonatomic) UIView *imageBg;
@property (strong, nonatomic) UIImageView *imageV;

@property (strong, nonatomic) UIView *characterV;
@property (strong, nonatomic) UILabel *nameL;
@property (strong, nonatomic) UILabel *priceL;

@end

@implementation ShoppingLastlyCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self == [super initWithFrame:frame]) {
        
        [self.contentView addSubview:self.imageBg];
        [self.imageBg addSubview:self.imageV];
        
        [self.contentView addSubview:self.characterV];
        [self.characterV addSubview:self.nameL];
        [self.characterV addSubview:self.priceL];
        
    }
    
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.imageBg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left);
        make.right.mas_equalTo(weakSelf.contentView.mas_right);
        make.top.mas_equalTo(weakSelf.contentView.mas_top);
        make.height.mas_equalTo(jisuan(190));
        
    }];
    
    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.imageBg.mas_centerX);
        make.centerY.mas_equalTo(weakSelf.imageBg.mas_centerY);
        make.width.mas_equalTo(jisuan(207));
        make.height.mas_equalTo(jisuan(150));
        
    }];
    
    [self.characterV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left);
        make.right.mas_equalTo(weakSelf.contentView.mas_right);
        make.top.mas_equalTo(weakSelf.imageBg.mas_bottom);
        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);
        
    }];
    
    [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.characterV.mas_centerX);
        make.top.mas_equalTo(weakSelf.characterV.mas_top).with.offset(jisuan(8));

    }];
    
    [self.priceL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.characterV.mas_centerX);
        make.bottom.mas_equalTo(weakSelf.characterV.mas_bottom).with.offset(-jisuan(8));
    }];
    
}


#pragma mark -lazy
- (UIView *)imageBg {
    
    if (!_imageBg) {
        
        _imageBg = [[UIView alloc] init];
        _imageBg.backgroundColor = Colorf2f2f2;
        
    }
    
    return _imageBg;
}

- (UIImageView *)imageV {
    
    if (!_imageV) {
        
        _imageV = [[UIImageView alloc] init];
        _imageV.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    
    return _imageV;
}

- (UIView *)characterV {
    
    if (!_characterV) {
        
        _characterV = [[UIView alloc] init];
        _characterV.backgroundColor = WhiteColor;
        
    }
    
    return _characterV;
}

- (UILabel *)nameL {
    
    if (!_nameL) {
        
        _nameL = [[UILabel alloc] init];
        _nameL.textColor = Color333333;
        _nameL.font = Font(20);
        _nameL.textAlignment = NSTextAlignmentCenter;
        _nameL.text = @"Apple MacBook";
        
    }
    
    return _nameL;
}

- (UILabel *)priceL {
    
    if (!_priceL) {
        
        _priceL = [[UILabel alloc] init];
        _priceL.textAlignment = NSTextAlignmentCenter;
        _priceL.textColor = Colorff0000;
        _priceL.font = Font(20);
        _priceL.text = @"￥11288.0";
    }
    
    return _priceL;
}

@end
